#include<fstream>
#include<iostream>
#include"count.h"
#include"LargeNumber.h"
#include"LargeNumberPtr.h"
#include"NumArray.h"

using namespace std;


void largeNumberPtrDemonstration() {
    LargeNumberPtr item( new LargeNumber(NumArray("123"), true) );
    LargeNumberPtr first_copy_item(item);
    LargeNumberPtr second_copy_item = first_copy_item;
    if(first_copy_item == second_copy_item) {
        cout << "correct" << endl;
    } else {
        cout << "something wrong" << endl;
    }
    LargeNumber * ptr = new LargeNumber(NumArray("124"), false);
    if(item == ptr) {
        cout << "something wrong" << endl;
    } else {
        cout << "correct " << abs(*ptr) << endl;
    }
    cout << "item is: " << *item << "; it must be -123" << endl;
    cout << "abs(item) = " << abs(*item) << endl;
    cout << "item + 124 = " << ( *ptr + *item ) << endl;
    delete ptr;
}

int main() {
    largeNumberPtrDemonstration();
    ofstream out("output.txt");
    ifstream in("input.txt");
    size_t file_length;
    in >> file_length;
    for (size_t i = 0; i < file_length; ++i) {
            char symbol = ' ';
            LargeNumber left;
            LargeNumber right;
            in >> left >> symbol >> right;
            LargeNumber result;
            int return_value = countResult(left, right, symbol, result);
            if ( return_value == 0 ) {
                    out << result;
            } else {
                    out << "undefined";
            }
            out << "\n";
    }
    out << endl;
    out.close();
    in.close();
    return 0;
}
